package com.guyu.common.web.util;


import cn.hutool.extra.spring.SpringUtil;
import org.springframework.core.env.Environment;

public class EnvUtils {

    public static Environment getEnv() {
        return SpringUtil.getApplicationContext().getEnvironment();
    }

    /**
     * 应用名称
     */
    public static String getApplicationName() {
        return SpringUtil.getApplicationName();
    }

    /**
     * 线上环境
     */
    public static boolean isReal() {
        return SpringUtil.getApplicationContext().getEnvironment().matchesProfiles("real");
    }

    /**
     * 预发环境
     */
    public static boolean isPre() {
        return SpringUtil.getApplicationContext().getEnvironment().matchesProfiles("pre");
    }

    /**
     * 稳定环境
     */
    public static boolean isStable() {
        return SpringUtil.getApplicationContext().getEnvironment().matchesProfiles("stable");
    }

    /**
     * 开发环境
     */
    public static boolean isDev() {
        return SpringUtil.getApplicationContext().getEnvironment().matchesProfiles("dev");
    }

    /**
     * 本地环境
     */
    public static boolean isLocal() {
        return SpringUtil.getApplicationContext().getEnvironment().matchesProfiles("local");
    }

}
